package Tools;

import java.util.Random;

public class RandomHelp {
	/**
	 * 	creat a String for random
	 * 
	 * 	@param	length num of String length
	 * 
	 * 	@author Mr.J.
	 * 
	 *  @since 	1.0
	 * */
	public static String randomString(int length){
		String str = "";
		char[] c = new char[length];
		for(int i = 0; i < length; i++){
			c[i] = (char) randomASCII();
		}
		str = new String(c);
		return str;
	}
	
	public static int randomASCII(){
		int random = 0;
		Random r = new Random();
		//ASCII for ABC....XYZ
		int i_ABC = r.nextInt(26) + 65;
		//ASCII for abc....xyz
		int i_abc = r.nextInt(26) + 97;
		//ASCII for 012....789
		int i_num = r.nextInt(10) + 48;

		int	randomControl = r.nextInt(3);
		switch (randomControl) {
		case 0:
			random = i_ABC;
			break;
		case 1:
			random = i_abc;
			break;
		case 2:
			random = i_num;
			break;
		}
		return random;
	}
}
